package com.woniuxy.couponassembly.listener;

import com.woniuxy.couponassembly.dao.UserCouponMapper;
import lombok.extern.slf4j.Slf4j;
import org.json.JSONException;
import org.json.JSONObject;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class RegRabbitListener {

    @Autowired
    private UserCouponMapper mapper;

    @RabbitListener(queues = "coupon.queue.message")
    public void doAfterRegSuccess(JSONObject jsonObject){
        try {
            int userId = jsonObject.getInt("userId");
            int couponId = jsonObject.getInt("couponId");
        } catch (JSONException e) {
            e.printStackTrace();
        }


      log.info("jsonobject,{}",jsonObject);
    }
}
